package com.mj.Queue;

import com.mj.linkedlist.LinkedList;
import com.mj.linkedlist.List;

/**
 * @Author: LDeng
 * @Date: 2021-02-24 11:35
 */
public class Deque<E> {

    private List<E> list=new LinkedList<>();


    public int size(){
        return list.size();
    }

    public boolean isEmpty(){
        return list.isEmpty();
    }

    public void clear(){
        list.clear();
    }

    public void enQueueRear(E element){//从尾部出队
        list.add(element);
    }
    public E deQueueFront(){//从头部出队

        return list.remove(0);
    }
    public void enQueueFront(E element){//从头部入队
        list.add(0,element);
    }
    public E deQueueRear(){//从尾部出队
        return list.remove(list.size()-1);
    }
    public E front(){//获取队头元素
        return list.get(0);
    }
    public E rear(){//获取队尾
        return list.get(list.size()-1);
    }
}
